classdef AnalogInLogic < Logic

  % DEFINE PROPERTIES
  properties (SetAccess = public)
    AnalogInActive = 0;
  end
  
  methods
    % CONSTRUCTOR
    function O = AnalogInLogic(varargin)
      global CG;
      O = setName(O,'AnalogIn');
           
      ModuleTypes = {'NI'};
      ModuleNames = {'AnalogIn'};
      ModulePars = {varargin};
      ID = addModules(O,ModuleTypes,ModuleNames,ModulePars);
      
      O.HW.IDs.AnalogIn = ID;
      
      % ESTABLISH TRIGGER CONNECTION BETWEEN TRIAL TRIGGGER
      addTriggerConnection(CG.Sessions.NI(O.HW.IDs.AnalogIn).SAI,...
        ['External'],... % FROM
        [CG.Parameters.Setup.Audio.Device{2},'/',CG.Parameters.Setup.Audio.TriggerChannel],... % TO
        'StartTrigger');

    end
      
    function prepareAnalogIn(O,AnalogInID)
      C_prepareNI(AnalogInID);
    end
    
    function startAnalogIn(O,AnalogInID)
      C_startNI(AnalogInID);
      O.AnalogInActive = 1;
    end

    function stopAnalogIn(O,AnalogInID)
      disp('AnalogIn stopping ...')
      C_stopNI(AnalogInID,0); % DONT SAVE DATA YET
      O.AnalogInActive = 0;
      disp('AnalogIn stopped.')      
    end    

  end
end